import { defineStore } from "pinia";
import { FactoryBaseInfo } from "@/api/porray/types";
import { factoryInfoReq } from "@/api/porray/api";
import { store } from "@/store";

export const washingFactoryStore = defineStore("factory", () => {
  const factory: FactoryBaseInfo = {};

  async function factoryInfoRequest() {
    let res = await factoryInfoReq();
    console.log("|--洗涤厂信息,实例", res);
    if (res.status == 200) {
      Object.assign(factory, { ...res.response });
    }
  }

  return {
    factory,
    factoryInfoRequest,
  };
});

/*
 * 将洗涤厂基本信息保存了全局状态
 * */
export function factoryStoreHook() {
  return washingFactoryStore(store);
}
